package com.zimmur.app.mocolink.background.util;

import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.zimmur.app.mocolink.service.RedisCacheUtil;


/**
 * 生成公钥
 * @author Administrator
 *
 */
public class PublicKeyUtil {
	@Resource
	private  RedisCacheUtil<String> redisCacheUtil;
	private  final String redisKey="mocolink_publicKey";
	public  String  getKey(){
		String strValue;
		if(redisCacheUtil.exists(redisKey)){
			strValue=redisCacheUtil.getCacheString(redisKey);
		}else{
			strValue=UUID.randomUUID().toString().replace("-", "").substring(0, 16);
			redisCacheUtil.setCacheString(redisKey, strValue);
			//不过期
			//redisCacheUtil.setTimeout(publicKey, 60*60*24);
		}
		return strValue;
	}
}
